package com.nlgc365.designpattern.Chapter04_Pattern.Creation.P02_Factory.Calculator.SimpleFactory;

/**
 * 简单工厂的作用, 解耦了实例的创建与使用过程, 并且去除了和具体的实现的依赖.
 * <p>
 * 问题: 如果对已有的所有实例进行替换?
 */
public class Client {

    public static void main(String[] args) {
        double result = 0.0;
        // 模拟有多个使用工厂的地方
        Calculator calculatorA = CalculatorFactory.getCalculator("+");
        Calculator calculatorB = CalculatorFactory.getCalculator("+");
        Calculator calculatorC = CalculatorFactory.getCalculator("+");
        result = calculatorA.calculate(1, 1);
        result = calculatorB.calculate(1, 1);
        result = calculatorC.calculate(1, 1);

    }
}
